package aapilast2;

public class SyncDemo3 {
    public static void main(String[] args) {
//        Thread t1 = new Thread("t1") {
//            public void run() {
//                Boo.doSome();
//            }
//        };
//        Thread t2 = new Thread("t2") {
//            public void run() {
//                Boo.doSome();
//            }
//        };
//        t1.start();
//        t2.start();
       new Thread(Boo::doSome).start();
       new Thread(Boo::doSome).start();
    }
}

class Boo {
    public  static void doSome() {
        synchronized(Boo.class){
            try {
                Thread t = Thread.currentThread();
                System.out.println(t.getName() + "正在执行doSome方法...");
                Thread.sleep(3000);
                System.out.println(t.getName() + "离开...");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}